PROJECT(WKIF)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_SYSTEM_NAME Linux)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(FindAllLibs)
include(BuildOption)

#EXECUTE_PROCESS(COMMAND protoc -I=${CMAKE_CURRENT_SOURCE_DIR} --cpp_out=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/message_struct.proto)

list(APPEND WKIF_SOURCE_DIR 
    ${CMAKE_CURRENT_SOURCE_DIR}
)

list(APPEND WKIF_SOURCE_FILE
    ${CMAKE_CURRENT_SOURCE_DIR}/WebKit.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/WebKitCaller.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/WebPage.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/WebElement.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/Zookit.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/message_struct.pb.cc
)

list(APPEND WKIF_INCLUDE_DIRECTORIES
    ${WKIF_SOURCE_DIR}
    ${WKIF_SOURCE_DIR}/include
)

list(APPEND WKIF_TARGET_INCLUDE_DIRECTORIES
    ${CMAKE_CURRENT_SOURCE_DIR}/KeyType.h
    ${CMAKE_CURRENT_SOURCE_DIR}/WebElement.h
    ${CMAKE_CURRENT_SOURCE_DIR}/WebKitCaller.h
    ${CMAKE_CURRENT_SOURCE_DIR}/WebKit.h
    ${CMAKE_CURRENT_SOURCE_DIR}/WebKitPort.h
    ${CMAKE_CURRENT_SOURCE_DIR}/WebPage.h
    ${CMAKE_CURRENT_SOURCE_DIR}/Zookit.h
    ${CMAKE_CURRENT_SOURCE_DIR}/message_struct.pb.h
)

INCLUDE_DIRECTORIES(${WKIF_INCLUDE_DIRECTORIES})

ADD_LIBRARY(wkif SHARED ${WKIF_SOURCE_FILE})
SET_TARGET_PROPERTIES(wkif PROPERTIES VERSION 1.1 SOVERSION 1)

INSTALL(TARGETS wkif
    LIBRARY DESTINATION lib)

INSTALL( FILES ${WKIF_TARGET_INCLUDE_DIRECTORIES}
    DESTINATION include/wkif)

list(APPEND WKIF_LIBRARIES
    wkif
)

if (BUILD_TEST)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/main WKIF_TEST_SOURCE_FILE)
endif(BUILD_TEST)

INCLUDE_DIRECTORIES(${WKIF_INCLUDE_DIRECTORIES})
LINK_LIBRARIES(${WKIF_LIBRARIES})

ADD_EXECUTABLE(wkif_test ${WKIF_TEST_SOURCE_FILE})
TARGET_LINK_LIBRARIES(wkif_test ${WKIF_TARGET_LIBRARIES})


